package rw.ac.kiosc.jdbc.school.orm;

import java.io.Serializable;
import java.util.Set;
import org.w3c.dom.*;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author antoine
 */
public class Department implements Serializable {

    private int departmentId;
    private String acronym;
    private int numberOfYears;
    private String name;
    private Set<Student> students;

    public Department() {
    }

    public Department(String acronym, int numberOfYears, String name, Set<Student> students) {
        this.acronym = acronym;
        this.numberOfYears = numberOfYears;
        this.name = name;
        this.students = students;
    }

    public Department(int departmentId, String acronym, int numberOfYears, String name, Set<Student> students) {
        this.departmentId = departmentId;
        this.acronym = acronym;
        this.numberOfYears = numberOfYears;
        this.name = name;
        this.students = students;
    }

    public String getAcronym() {
        return acronym;
    }

    public void setAcronym(String acronym) {
        this.acronym = acronym;
    }

    public int getDepartmentId() {
        return departmentId;
    }

    public void setDepartmentId(int departmentId) {
        this.departmentId = departmentId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getNumberOfYears() {
        return numberOfYears;
    }

    public void setNumberOfYears(int numberOfYears) {
        this.numberOfYears = numberOfYears;
    }

    public Set<Student> getStudents() {
        return students;
    }

    public void setStudents(Set<Student> students) {
        this.students = students;
    }

    public Node getDepartmentNode(Document document) {
        Element departmentNode = document.createElement("department");
        departmentNode.setAttribute("departmentId", this.getDepartmentId() + "");
        departmentNode.setAttribute("acronym", this.getAcronym() + "");
        departmentNode.setAttribute("name", this.getName() + "");
        departmentNode.setAttribute("numberOfYears", this.getNumberOfYears() + "");
        for (Student student : getStudents()) {
            departmentNode.appendChild(student.getStudentNode(document));
        }
        return departmentNode;
    }
}
